<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language = "java"	import="java.io.*,java.sql.*" %>
<head>
<title>Duediligencebarbados</title>

<%@include file="../dbcon.jsp"%>
<%
// Not Login or User Not Admin
	/*if ( session.getAttribute("SES_USERSNO") == null || (Integer)session.getAttribute("SES_USERTYPE") != 1  )
	{
		response.sendRedirect("index.jsp");
		return;
	}*/
	
	int iSno = 0;
	int iRecType = 1;
	int iUserType = 1;
	String sTmp = "";
	
	String sUserName	= "";			
	String sPwd			= "";
	String sName		= "";
	String sAddress		= "";
	String sContactNos	= "";
	String sEmail		= "";
	
	int iRealestateFlag = 1;
	int iVechileFlag = 1;
	int iPersonFlag = 1;
	int iBusinessFlag = 1;
							

	sTmp = request.getParameter("UserID");
	if ( sTmp != null && !sTmp.equals("") )
		iSno = Integer.parseInt(sTmp);
	sTmp = request.getParameter("RecType");
	if ( sTmp != null && !sTmp.equals("") )
		iRecType = Integer.parseInt(sTmp);		
		
System.out.println("iSno : "+ iSno);
		
	if ( iSno > 0 ) // Edit
	{
		iRecType = 2;
		Statement Stmt = null;
	    ResultSet Rs = null;
		try
		{
			String sQry = "select * from tbl_user_master where reg_flag != 3 ";
			sQry += "and userid="+ iSno;
		System.out.println(sQry);
			Stmt = Con.createStatement();
			Rs = Stmt.executeQuery(sQry);
			if ( Rs.next() )
			{
				sUserName = Rs.getString("user_name");;			
				sPwd = Rs.getString("pwd");;
				sName = Rs.getString("person_name");;
				sAddress = Rs.getString("address");;				
				sContactNos	= Rs.getString("contactno");;
				sEmail = Rs.getString("emailid");;
				
				iRealestateFlag = Rs.getInt("realestate_flag");
				iVechileFlag = Rs.getInt("vechile_flag");
				iPersonFlag = Rs.getInt("person_flag");
				iBusinessFlag = Rs.getInt("business_flag");
		
			}
		}catch(Exception e){ System.out.println(e); }
		
		if (Rs != null ) Rs.close();
		if (Stmt != null ) Stmt.close();
		if (Con != null ) Con.close();
	}
%>

<!-- Common Style -->	
	<link href="../css/default.css" rel="stylesheet" type="text/css" />
	<link href="../css/main.css" rel="stylesheet" type="text/css" />		
<!-- Common Validation -->				
	<script src='../js/validation.js' language='javascript' ></script>		
	<script src='../js/common.js' language='javascript' ></script>
<!-- jquery main -->				
	<script type="text/JavaScript" src="../jquery/jquery-1.4.2.min.js"></script>			
<!-- Form Field Validation -->			
    <link rel="stylesheet" href="../css/validationEngine.jquery.css" type="text/css"/>
    <script src="../js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"> </script>	
<!-- Ajax -->
	<script src='../ajax/ajax_fn.js' language='javascript' ></script>	
<!-- Menu -->	
	<link type="text/css" href="../menu/menu.css" rel="stylesheet" />
    <script type="text/javascript" src="../menu/menu.js"></script>
	
<script type="text/JavaScript">
	var vLoginStatus = <%=(String)session.getAttribute("SES_USERSNO")%>;
	var vUserType = <%=iUserType%>;	
/* Form Validation */
	jQuery(document).ready(function(){
		// binds form submission and fields to the validation engine
		jQuery("#frmUser").validationEngine();
	});
	
</script>

<script type="text/JavaScript">
	var vLoginStatus = 0;
	var vUserType = 0;
<% if ( session.getAttribute("SES_USERSNO") != null ) { %>
	vLoginStatus = <%=(String)session.getAttribute("SES_USERSNO")%>;
	vUserType = <%=(Integer)session.getAttribute("SES_USERTYPE")%>;
<% } %>

	window.onload=function()
	{
		document.getElementById("txt_name").focus();
		CommonValidation();				
	}
	document.onkeypress = GBLVdn_StopRKey;

			
	function CheckDuplicate(p_id,p_value)
	{
		p_value = GBLVdn_Trim(p_value);
		if ( p_value == "" || p_value == null ) return;
		
		var frm = document.frmUser;
		if ( p_id == 1 ) // User Name
		{
//			alert(document.getElementById("unameStatus"));
			var vCond = "user_name='"+ frm.txt_uname.value +"'";
			call_DBDuplicate("tbl_user_master",vCond,frm.txt_uname,document.getElementById("unameStatus"));
		}
	}
	
	function validation()
	{
		//alert(document.getElementById("hid_DupRec").value);
		if ( document.getElementById("hid_DupRec").value == "1" )
		{
			document.getElementById("txt_uname").focus();
			return false;
		}
		
		//document.frmUser.submit();
		return true;
	}
</script>
</head>
	
<body >
<form id="frmUser" name="frmUser" method="post" action="frm_user_add.jsp">
<input type='hidden' name='hid_RecType' id='hid_RecType' value='<%=(iSno<=0)?"1":"2"%>'>
<input type='hidden' name='hid_DupRec' id='hid_DupRec' value='0'>
<input type='hidden' name='hid_RecSno' id='hid_RecSno' value='<%=iSno%>'>
<table width="100%" cellpadding="0" cellspacing="0" border="0" >
<tr><td align="center">
<table width="1004px" cellpadding="0" cellspacing="0" border="0" class="formbk" >
<tr> <td align="center" >
<table width="100%" cellpadding="3" cellspacing="3" border="0"  id="wrapper">
<tr><td valign="top"><script src="../js/top.js"></script></td></tr>
			<tr>
			<td width="50%" align="center">
			<table width="100%" cellpadding="0" cellspacing="0" border="0" >
			<tr><td align="center" >&nbsp;</td></tr>			
			<tr><td align="center" class="mainhead" >User Informations</td></tr>
			<tr><td align="center" >
				<table width="60%" cellpadding="1" cellspacing="1" border="0" >
				<tr><td colspan='2' align="left" >&nbsp;</td></tr>				
				<tr><td align="left" valign="middle" colspan='2' class="bodytitle" >	Personal Details</td></tr>
				<tr><td colspan='2' align="left" ><hr align="left" width="40%" /></td></tr>
				<tr>
					<td valign="top" align="left" >Person Name</td>
					<td valign="top" align="left" ><input type="text" size="30" value='<%=sName%>' class="validate[required] text-input" name="txt_name" id="txt_name" tabindex="2" onkeypress="return GBLVdn_OnlyAlphabetics(event);" maxlength="20" />
					  &nbsp;<b class='mandatory' >*</b>&nbsp; </td>
					
				</tr>
				<tr>
					<td valign="top" align="left" > Address </td>
					<td valign="top" align="left" >
						<textarea rows="4" cols="30" class="validate[required] text-input" name="ta_address" id="ta_address" tabindex="3" ><%=sAddress%></textarea>&nbsp;<b class='mandatory' >*</b>&nbsp;
					</td>				
				</tr>
				<tr><td colspan='2' align="left" >&nbsp;</td></tr>				
				<tr><td align="left" valign="middle" colspan="2" class="bodytitle">Security Details</td></tr>
				<tr><td colspan='2' align="left" ><hr align="left" width="40%" /></td></tr>
				<tr>
					
					<td valign="top" align="left" >User Name</td>
					<td valign="top" align="left" width="65%">
<% if (iRecType == 1) { %>					
						<input type="text" size="30" value='<%=sUserName%>' class="validate[required,minSize[6]] text-input" name="txt_uname" id="txt_uname" tabindex="4" onblur="CheckDuplicate(1,this.value);" maxlength="20" onkeydown="vSpaceAllow=false;" />&nbsp;<b class='mandatory' >*</b>&nbsp;<span id="unameStatus" name="unameStatus"></span>
<% }else { %>						
					<%=sUserName%>
<% }%>				
					</td>		
				</tr>
				<tr>
					<td valign="top" align="left" >Password</td>
					<td valign="top" align="left" >
						<input type="password" size="30" value='<%=sPwd%>' class="validate[required,minSize[6]] text-input" name="txt_pwd" id="txt_pwd" tabindex="5" maxlength="20"/>&nbsp;<b class='mandatory' >*</b>&nbsp;
						<img src="../images/key.png" width="25" height="25" border='0' >
					</td>					
				</tr>
				<tr>
					
					<td valign="top" align="left" >Confirm Password</td>
					<td valign="top" align="left" >
						<input type="password" size="30" value='<%=sPwd%>' class="validate[required,equals[txt_pwd]] text-input" name="txt_cpwd" id="txt_cpwd" tabindex="6" maxlength="20"/>&nbsp;<b class='mandatory' >*</b>&nbsp;
						<img src="../images/key.png" width="25" height="25" border='0' >
					</td>				
				</tr>	
				<tr><td colspan='2' align="left" >&nbsp;</td></tr>				
				<tr><td align="left" valign="middle" colspan="2" class="bodytitle">Contact Details</td></tr>
				<tr><td colspan='2' align="left" ><hr align="left" width="40%" /></td></tr>
				<tr>
					<td valign="top" align="left" >Mobile/Phone</td>
					<td valign="top" align="left" width="70%" >
						<input type="text" size="30" value='<%=sContactNos%>' class="validate[required,custom[integer]] text-input" name="txt_contactno" id="txt_contactno" tabindex="7" onkeypress="return GBLVdn_onlyNumbers(event);" maxlength="12" />&nbsp;<b class='mandatory' >*</b>&nbsp;
						<img src="../images/mobile.png" border="0" width="15" height="25" />
					</td>				
				</tr>
				<tr>
					<td valign="top" align="left" >Email</td>
					<td valign="top" align="left" >
						<input type="text" size="30" value='<%=sEmail%>' class="validate[required,custom[email]] text-input" name="txt_emailis" id="txt_emailis" tabindex="8" maxlength="35" onkeydown="vSpaceAllow=false;" />&nbsp;<b class='mandatory' >*</b>&nbsp;
						<img src="../images/email.png" border="0" width="25" height="25" />
					</td>			
				</tr>
				<tr><td align="center" >&nbsp;</td></tr>			
				<tr><td align="left" class="bodytitle" >User Activity</td></tr>
				<tr><td colspan='2' align="left" ><hr align="left" width="40%" /></td></tr>
				<tr>
					<td valign="top" align="left" > Permission </td>
					<td ><input type='checkbox' value='1' id='ck_RealestateFlag' name='ck_RealestateFlag'  />Real Estate&nbsp;&nbsp;
					<input type='checkbox' value='1' id='ck_VechileFlag' name='ck_VechileFlag' >Vechiles&nbsp;&nbsp;
				</td></tr>
				<tr><td>&nbsp;</td>
				<td>
					<input type='checkbox' value='1' id='ck_PersonFlag' name='ck_PersonFlag'  />Persons&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type='checkbox' value='1' id='ck_BusinessFlag' name='ck_BusinessFlag'  />Business&nbsp;&nbsp;
				</td></tr>
				</table></td></tr>
				<tr><td align="left" >&nbsp;</td></tr>
				<tr><td align="center" ><input class="regular" type="submit" onclick="return validation();" value="<%=(iSno==0)?"Save":"Update"%>" /></td></tr>
				<!-- <tr><td align="center" ><a href="#" onclick="validation();" ><img src="../images/bt_save.png" border="0" ></a></td></tr> -->
				<tr><td align="left" >&nbsp;</td></tr>
			</table></td></tr>
</table></td></tr>
<tr><td align="center"><script src="../js/bottom.js"></script></td></tr>
</table></td></tr>
</table></td></tr></table>
</form>
</body>
</html>
